import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _dec2, _class;

import React, { PureComponent } from 'react';
import { Table, Popconfirm } from 'antd';
import { Bind } from 'lodash-decorators';
import { Button as ButtonPermission } from 'components/Permission';
import intl from 'utils/intl';
import { tableScrollWidth } from 'utils/utils';
import { operatorRender } from 'utils/renderer';
var TableList = (_dec = Bind(), _dec2 = Bind(), (_class = /*#__PURE__*/function (_PureComponent) {
  _inherits(TableList, _PureComponent);

  var _super = _createSuper(TableList);

  function TableList() {
    _classCallCheck(this, TableList);

    return _super.apply(this, arguments);
  }

  _createClass(TableList, [{
    key: "editModal",
    value:
    /**
     * 编辑
     *
     * @param {*} record
     * @memberof ListTable
     */
    function editModal(record) {
      var onGetRecordData = this.props.onGetRecordData;
      onGetRecordData(record);
    }
    /**
     * 删除
     *
     * @param {*} record
     * @memberof ListTable
     */

  }, {
    key: "deleteData",
    value: function deleteData(record) {
      var onDelete = this.props.onDelete;
      onDelete(record);
    }
  }, {
    key: "render",
    value: function render() {
      var _this = this;

      var _this$props = this.props,
          _this$props$listConfi = _this$props.listConfig,
          listConfig = _this$props$listConfi === void 0 ? {} : _this$props$listConfi,
          loading = _this$props.loading,
          _this$props$paginatio = _this$props.pagination,
          pagination = _this$props$paginatio === void 0 ? {} : _this$props$paginatio,
          onChangePage = _this$props.onChangePage,
          path = _this$props.match.path;
      var columns = [{
        title: intl.get('cfile.fileUpload.model.fileUpload.bucketName').d('分组'),
        dataIndex: 'bucketName',
        width: 200
      }, {
        title: intl.get('cfile.fileUpload.model.fileUpload.directory').d('上传目录'),
        dataIndex: 'directory',
        width: 200
      }, {
        title: intl.get('cfile.fileUpload.model.fileUpload.contentType').d('文件分类'),
        dataIndex: 'contentTypeMeaning',
        width: 200
      }, {
        title: intl.get('cfile.fileUpload.model.fileUpload.fileFormat').d('文件格式'),
        dataIndex: 'fileFormat'
      }, {
        title: intl.get('cfile.fileUpload.model.fileUpload.storageSize').d('文件大小限制'),
        dataIndex: 'storageSize',
        width: 150
      }, {
        title: intl.get('cfile.fileUpload.model.fileUpload.storageUnit').d('文件大小单位'),
        dataIndex: 'storageUnitMeaning',
        width: 150
      }, {
        title: intl.get('cpaas.common.button.action').d('操作'),
        key: 'option',
        fixed: 'right',
        width: 120,
        render: function render(_, record) {
          var operators = [];
          operators.push({
            key: 'edit',
            ele: /*#__PURE__*/React.createElement(ButtonPermission, {
              type: "text",
              permissionList: [{
                code: "".concat(path, ".button.edit"),
                type: 'button',
                meaning: '文件上传配置-编辑'
              }],
              onClick: function onClick() {
                return _this.editModal(record);
              }
            }, intl.get('cpaas.common.button.edit').d('编辑')),
            len: 2,
            title: intl.get('cpaas.common.button.edit').d('编辑')
          }, {
            key: 'delete',
            ele: /*#__PURE__*/React.createElement(Popconfirm, {
              title: intl.get('cpaas.common.message.confirm.delete').d('是否删除此条记录？'),
              onConfirm: function onConfirm() {
                return _this.deleteData(record);
              }
            }, /*#__PURE__*/React.createElement(ButtonPermission, {
              type: "text",
              permissionList: [{
                code: "".concat(path, ".button.delete"),
                type: 'button',
                meaning: '文件上传配置-删除'
              }]
            }, intl.get('cpaas.common.button.delete').d('删除'))),
            len: 2,
            title: intl.get('cpaas.common.button.delete').d('删除')
          });
          return operatorRender(operators, record, {
            limit: 3
          });
        }
      }];
      return /*#__PURE__*/React.createElement(Table, {
        bordered: true,
        columns: columns,
        scroll: {
          x: tableScrollWidth(columns)
        },
        rowKey: "uploadConfigId",
        dataSource: listConfig.content || [],
        pagination: pagination,
        loading: loading,
        onChange: function onChange(page) {
          return onChangePage(page);
        }
      });
    }
  }]);

  return TableList;
}(PureComponent), (_applyDecoratedDescriptor(_class.prototype, "editModal", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "editModal"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "deleteData", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "deleteData"), _class.prototype)), _class));
export { TableList as default };